import Immutable from 'immutable';

const defaultState = Immutable.fromJS({
  routeInfo: {
    selectedTab: 'cookbook',
    cateType: 'category',
    cateAside: ''
  }
})

const reducer = (state = defaultState, action) => {
  switch(action.type) {
    case 'changeSelected': 
      return state.setIn(['routeInfo', 'selectedTab'], action.selectedTab)
      // return {
      //   routeInfo: {
      //     ...state.routeInfo,
      //     selectedTab: action.selectedTab
      //   }
      // }
    case 'changeCateType': 
      return state.setIn(['routeInfo', 'cateType'], action.cateType)
      // return {
      //   routeInfo: {
      //     ...state.routeInfo,
      //     cateType: action.cateType
      //   }
      // }
    case 'changeCateAside': 
      return state.setIn(['routeInfo', 'cateAside'], action.cateAside)
      // return {
      //   routeInfo: {
      //     ...state.routeInfo,
      //     cateAside: action.cateAside
      //   }
      // }
    default: 
      return state
  }
}

export default reducer